package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/path")
public class PathServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1、使用请求转发实现跳转页面
        //http://localhost:8080/path.html
        //req.getRequestDispatcher("/path.html").forward(req,resp);
        //2、request作用域携带数据
        req.setAttribute("name","admin");
        //3、跳转到param
        //http://localhost:8080/param
        //req.getRequestDispatcher("/param").forward(req,resp);


        //2、重定向   /  ?
        //resp.sendRedirect(req.getContextPath()+"/path.html");
        resp.sendRedirect(req.getContextPath()+"/param");
    }
}
